#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Last Update: 2010/10/29 20:44:09

'''docstring
'''

__revision__ = '0.1'
__author__ = 'lxd'
import win32gui,win32con
import tools

class Key():
    def __init__(self,log,window):
        self.log = log
        self.hwnd= window.hwnd

    def press(self,code):
        win32gui.SendMessage(self.hwnd, win32con.WM_KEYDOWN, ord(code), 0)
        win32gui.SendMessage(self.hwnd, win32con.WM_KEYUP, ord(code), 0)
        win32gui.SendMessage(self.hwnd, win32con.WM_CHAR, ord(code), 0)
        self.log.debug('press key (%s)' %code)
        tools.sleep()

if __name__ == '__main__':
    #import config
    #import window
    #w = window.Window()
    #k = Key(config.log,w)
    #k.press('8')
    import win32process
    import win32api
    import win32gui
    import win32con
    import time

    hwnd = 462616
    hwnd = 0x000C0684
    #win32gui.PostMessage(hwnd, win32con.WM_KEYDOWN, ord('1'), 0x20001)

    win32gui.SendMessage(hwnd, win32con.WM_ACTIVATE, win32con.WA_ACTIVE, 0)
    win32gui.PostMessage(hwnd, win32con.WM_KEYDOWN, ord('1'), 0x20001)
    win32gui.PostMessage(hwnd, win32con.WM_KEYUP, ord('1'), 0x20001)
    #win32gui.PostMessage(hwnd, win32con.WM_CHAR, ord('1'), 0x20001)
